package ek.ao;

public class KeyFactory {

    /** Unique instance */
    private static KeyFactory instance = null;

    /**
     * 
     * 
     */
    public KeyFactory() {
    }

    /**
     * Get or create (if null) an instance of the KeyFactory Object in order to call the getKeyValue
     * method
     * 
     * @return KeyFactory instance
     */
    public static KeyFactory getInstance() {
        if (instance == null) {
            instance = new KeyFactory();
        }
        return instance;
    }

    /**
     * Return the translated String according to the three parameters
     * 
     * @param moduleName Name of the module
     * @param groupName Name of the group
     * @param keyName name of the key
     * @return
     */
    public static String getKeyValue(String moduleName, String groupName, String keyName) {
        // Call the method for the current language selected
        String res = MainModel.getCurrentLang().getKeyValue(moduleName, groupName, keyName);

        // Return the concatened name of the key if not defined
        return (!"".equals(res)) ? res : moduleName + "." + groupName + "." + keyName;
    }
}
